<template>
  <div class="container-subjects">
    <!-- 新增学科对话框 -->
    <el-dialog title="新增学科" :visible.sync="addDialogVisible" width="50%">
      <!-- 表单区域 -->
      <el-form
        :model="addForm"
        :rules="addRules"
        ref="addFormRef"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="学科名称" prop="subjectName">
          <el-input v-model="addForm.subjectName"></el-input>
        </el-form-item>
        <el-form-item label="是否显示">
          <el-switch v-model="addForm.isFrontDisplay"></el-switch>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="addSub">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 修改学科对话框 -->
    <el-dialog title="修改学科" :visible.sync="editDialogVisible" width="50%">
      <!-- 表单区域 -->
      <el-form
        :model="editForm"
        :rules="editRules"
        ref="editRef"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="修改学科" prop="subjectName">
          <el-input v-model="editForm.subjectName"></el-input>
        </el-form-item>
        <el-form-item label="是否显示">
          <el-switch v-model="editForm.isFrontDisplay"></el-switch>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="editSub">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { update, add } from "@/api/base/users";
export default {
  name: "SubjectsAdd",

  data() {
    return {
      // title: "新增学科",
      dialogFormVisible: false,
      dialogFormVisibles: false,
      formLabelWidth: "120px"
    };
  },
  methods: {
    handleUpdate(item) {
      console.log(item);
      this.dialogFormVisibles = true;
      this.article = item.subjectName;
      this.artID = item.id;
    },
    handleUpdate(item) {
      console.log(item);
      this.dialogFormVisibles = true;
      this.article = item.subjectName;
      this.artID = item.id;
    },
    async handleisOk() {
      this.dialogFormVisibles = false;
      await update({
        id: this.artID,
        subjectName: this.article
      });
      this.loadSubject();
    }
  }
};
</script>

<style scoped ></style>
